/*
 * This calendar application is brought to you
 * by Group 3 of User Interface Programming II, vt11.
 *
 * Group Members:
 * Pooya | Flora | Monica | Can
 */
package vical.utility;

import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.Graphics;
import java.awt.Point;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.image.BufferedImage;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JMenuBar;
import javax.swing.JPanel;
import javax.swing.JRootPane;
import javax.swing.RootPaneContainer;
import javax.swing.SwingUtilities;

/**
 * This class draws around a component on the GlassPane
 * @author Pooya
 */
class MyGlassPane extends JPanel {

    private Component component;
    private Graphics graphic;

    /**
     * Initializer
     * @param _component
     * @param graphic
     */
    public MyGlassPane(Component _component, Graphics graphic) {
        this.component = _component;
        this.graphic = graphic;
        this.setOpaque(false);
    }

    /**
     * Draws a rectangle around the specified component
     * @param g
     */
    @Override
    public void paintComponent(Graphics g) {
        g.setColor(Color.red);
        // Convert coordination of component to coordination of root pane
        Point containerPoint = SwingUtilities.convertPoint(
                component.getParent(),
                new Point(component.getX(), component.getY()),
                (SwingUtilities.getRootPane(component)));

        int thickness = 4;

        // Draw 4 rectangles to make it thick
        for (int i = 0; i <= thickness; i++) {
            g.draw3DRect(containerPoint.x - i, containerPoint.y - i, component.getWidth() + 2 * i, component.getHeight() + 2 * i, true);
        }

        g.setColor(Color.black);
    }
}
